import 'package:flutter/material.dart';

class WelcomeTitle extends StatefulWidget {
  const WelcomeTitle({super.key});

  @override
  State<WelcomeTitle> createState() => _WelcomeTitleState();
}

class _WelcomeTitleState extends State<WelcomeTitle> {
  // 初始位置
  late double _yOffset = 60;

  bool isMobileLayout(BuildContext context){
    return MediaQuery.of(context).size.width < 600;
  }

  @override
  void initState() {
    super.initState();
    Future.delayed(const Duration(milliseconds: 100),(){
      setState(() {
        _yOffset = 0;
      });
    });
  }

  @override
  Widget build(BuildContext context) {
    return SizedBox(
      width: MediaQuery.of(context).size.width,
      child: Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          AnimatedContainer(
            duration: const Duration(milliseconds: 500),
            curve: Curves.decelerate,
            transform: Matrix4.translationValues(0, _yOffset, 0),
            child: Text(
              "Hi 欢迎你",
              style: TextStyle(
                  fontSize: isMobileLayout(context)?26:50,
                  color: Colors.white
              ),
            ),
          ),
          AnimatedContainer(
            duration: const Duration(milliseconds: 550),
            curve: Curves.decelerate,
            transform: Matrix4.translationValues(0, _yOffset, 0),
            child: Text(
              "让我们拥抱梵高的星空",
              style: TextStyle(
                  fontSize: isMobileLayout(context)?20:29,
                  color: Colors.white
              ),
            ),
          ),
          AnimatedContainer(
            duration: const Duration(milliseconds: 600),
            curve: Curves.decelerate,
            transform: Matrix4.translationValues(0, _yOffset, 0),
            child: Text(
              "用星辉点亮旅程",
              style: TextStyle(
                  fontSize: isMobileLayout(context)?20:29,
                  color: Colors.white
              ),
            ),
          ),
        ],
      ),
    );
  }
}
